package com.adcc.loadsheet.monitor.vo;

import com.adcc.loadsheet.monitor.entity.ServerLog;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.base.Strings;

/**
 * 日志视图
 */
public class ServerLogVO extends BaseVO<ServerLog> {

    // ID
    private Long id;

    // 服务名称
    private String name;

    // 日志类型
    private String type;

    // 日志内容
    private String content;

    // 创建时间
    private String createTime;

    /**
     * 构造函数
     */
    public ServerLogVO(){

    }

    /**
     * 构造函数
     * @param serverLog
     */
    public ServerLogVO(ServerLog serverLog){
        this.id = serverLog.getId();
        this.name = serverLog.getName();
        this.type = serverLog.getType().toString();
        this.content = Strings.nullToEmpty(serverLog.getContent());
        this.createTime = Strings.nullToEmpty(serverLog.getCreateTime());
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    @Override
    public ServerLog toEntity() {
        return null;
    }

    @Override
    public String toJSON() throws JsonProcessingException {
        return JSON.toJSONString(this);
    }
}
